package com.fangcai.es.practise2_qq_user_search.controller;

import com.fangcai.es.common.response.PageResponse;
import com.fangcai.es.common.response.ResponseMsg;
import com.fangcai.es.practise2_qq_user_search.entity.QqUser;
import com.fangcai.es.practise2_qq_user_search.service.QqUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author MouFangCai
 * @date 2020/10/13 15:47
 * @description
 */
@RestController
@RequestMapping ("es/qqUser")
public class QqUserController {


    @Autowired
    private QqUserServiceImpl qqUserService;


    /**
     * QQ 用户 ：中文 + 拼音 混合检索
     *
     * @param queryStr
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping ("listByQuery")
    public ResponseMsg listByQuery (@RequestParam ("queryStr") String queryStr,
                                    @RequestParam (defaultValue = "1") Integer pageNum,
                                    @RequestParam (defaultValue = "10") Integer pageSize) {

        PageResponse<QqUser> page = qqUserService.listByStr(queryStr, pageNum, pageSize);
        return new ResponseMsg(page);
    }


}
